package com.cowin.config;

import java.util.ArrayList;
import java.util.List;

/**
 * Copyright (C), 1998-2018, 奇瑞信息
 *
 * @author : 于超
 * @Date: 2019/9/18 10:19
 * @Description:
 */
public final class PermitAllUrl {

    /**
     * 监控中心和swagger 需要访问的url
     */
    private static final String[] ENDPOINTS = {
            "/inf/**",
            "/websocket/**",
            "/services/**",
            "/v2/api-docs/**", "/swagger-ui.html", "/swagger-resources/**", "/webjars/**",
            "/tm/sys/user/login",
            "/ky/line/state/monitor","/inf/bdc/interpret/vehicle/job","/ky/device/state/pmc/**"
    };

    /**
     * 需要放开权限的url
     *
     * @param urls 自定义的url
     * @return 自定义的url和监控中心需要访问的url集合
     */
    public static String[] permitAllUrl(String... urls) {
        if (urls == null || urls.length == 0) {
            return ENDPOINTS;
        }

        List<String> list = new ArrayList<>();
        for (String url : ENDPOINTS) {
            list.add(url);
        }
        for (String url : urls) {
            list.add(url);
        }

        return list.toArray(new String[list.size()]);
    }

}
